var app = getApp()
var baseutil = require('../../utils/baseutil.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        name: "个人中心",
        userHead: null,
        nickName: null,
        TUserInfo: null, //用户信息
        isLogin: false,
        marginTop: '',
        navTo: ''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        var that = this;
        that.setData({
            marginTop: app.globalData.statusBarHeight + 'px',
            navTo: app.globalData.navHeight + 'px'
        })
    },
    Gotback() {
        wx.navigateBack({
            delta: 1,
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        this.setData({
            TUserInfo: app.globalData.TUserInfo,
            isLogin: app.globalData.isLogin
        })
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    },

    bindPhone: function() {
        wx.navigateTo({
            url: '../bindphone/bindphone'
        })
    },
    updateData: function(TUserInfo) {
        baseutil.log("绑定成功")
        this.setData({
            TUserInfo: TUserInfo
        })
    },
    standard: function() {
        if (!this.data.isLogin) {
            this.wetoast.toast({
                title: '请先绑定!',
                duration: 500
            })
            setTimeout(function() {
                wx.navigateTo({ url: '/pages/bindphone/bindphone' })
            }, 500)

            return;
        }
        wx.navigateTo({
            url: '../standard/standard',
        })

    },
    goPassengerList: function() {
        if (!this.data.isLogin) {
            this.wetoast.toast({
                title: '请先绑定!',
                duration: 500
            })
            setTimeout(function() {
                wx.navigateTo({ url: '/pages/bindphone/bindphone' })
            }, 500)

            return;
        }
        wx.navigateTo({
            url: '../passenger/passengerList/passengerList',
        })

    },
    flightorder: function() {
        if (!this.data.isLogin) {
            this.wetoast.toast({
                title: '请先绑定!',
                duration: 500
            })
            setTimeout(function() {
                wx.navigateTo({ url: '/pages/bindphone/bindphone' })
            }, 500)

            return;
        }
        wx.navigateTo({
            url: '../myOrder/myOrder?type=' + 0,
        })
    },
    trainorder: function() {
        if (!this.data.isLogin) {
            this.wetoast.toast({
                title: '请先绑定!',
                duration: 500
            })
            setTimeout(function() {
                wx.navigateTo({ url: '/pages/bindphone/bindphone' })
            }, 500)

            return;
        }
        wx.navigateTo({
            url: '../myOrder/myOrder?type=' + 1,
        })
    },
    allorder: function() {
        if (!this.data.isLogin) {
            this.wetoast.toast({
                title: '请先绑定!',
                duration: 500
            })
            setTimeout(function() {
                wx.navigateTo({ url: '/pages/bindphone/bindphone' })
            }, 500)

            return;
        }
        wx.navigateTo({
            url: '../myOrder/myOrder?type=' + 0,
        })
    },
    goPhone() {
        wx.makePhoneCall({
            phoneNumber: '400-720-9939'
        })
    },
    internationalTicketOrder() {
        this.wetoast.toast({
            title: '该功能尚未开通,敬请期待!',
            duration: 1000
        })
    },
    hotelOrder() {
        this.wetoast.toast({
            title: '该功能尚未开通,敬请期待!',
            duration: 1000
        })
    }
})